<!-- saved from url=(0014)about:internet -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>performance_tips.mxml</title>
<link rel="stylesheet" type="text/css" href="../SourceStyles.css"/>
</head>

<body><pre><span class="MXMLProcessing_Instruction">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</span>
<span class="MXMLComponent_Tag">&lt;mx:Application</span><span class="MXMLDefault_Text"> xmlns:mx=&quot;</span><span class="MXMLString">http://www.adobe.com/2006/mxml</span><span class="MXMLDefault_Text">&quot; layout=&quot;</span><span class="MXMLString">vertical</span><span class="MXMLDefault_Text">&quot; horizontalAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot; viewSourceURL=&quot;</span><span class="MXMLString">srcview/index.html</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
    <span class="MXMLSpecial_Tag">&lt;mx:Script&gt;</span>
        <span class="ActionScriptOperator">&lt;!</span><span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptDefault_Text">CDATA</span><span class="ActionScriptBracket/Brace">[</span>
            <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span>.<span class="ActionScriptDefault_Text">collections</span>.<span class="ActionScriptDefault_Text">ArrayCollection</span>;
            <span class="ActionScriptReserved">import</span> <span class="ActionScriptDefault_Text">mx</span>.<span class="ActionScriptDefault_Text">managers</span>.<span class="ActionScriptDefault_Text">CursorManager</span>;

            <span class="ActionScriptReserved">private</span> <span class="ActionScriptReserved">const</span> <span class="ActionScriptDefault_Text">explanation1</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">&quot;We must pay attention to how we use bindable collections declared as datasources for components. Do we really want to notify every change for this collection or just want to display changes between states &apos;atomically&apos; (once a full set of changes has been applied)? In this example, the list is displayed twice faster if we do not update its binded collection for every  new entry, but just once, when the input data has been created over a temporarlly list.&quot;</span>;
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptReserved">const</span> <span class="ActionScriptDefault_Text">explanation2</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">String</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptString">&quot;Remember &apos;breaks&apos;!!! Useful once we&apos;ve done all the required work inside a loop. Even in nested loops, using a label we can skip the remaining iterations and save some precious time.Also &apos;continue&apos; can be useful if we want to skip some code inside a single loop iteration and go to the next one.&quot;</span>;

            <span class="ActionScriptComment">// ----------------------- TEST 1 - BINDINGS [START] ----------------
</span>            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>            
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">colA</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">ArrayCollection</span>;
            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>            
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">colB</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">ArrayCollection</span>;
            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">time1A</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> 0;
            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">time1B</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> 0;            
            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">listSize</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 20000;
                        
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">startTest1</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>                
                <span class="ActionScriptDefault_Text">createListA</span><span class="ActionScriptBracket/Brace">()</span>;
                <span class="ActionScriptDefault_Text">createListB</span><span class="ActionScriptBracket/Brace">()</span>;                                                
            <span class="ActionScriptBracket/Brace">}</span>    
            
            <span class="ActionScriptComment">// Handle user list size change
</span>            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">listSizeChangeHandler</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptDefault_Text">listSize</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">listSizeInput</span>.<span class="ActionScriptDefault_Text">text</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptBracket/Brace">}</span>        
            
            <span class="ActionScriptComment">// Slow version
</span>            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">createListA</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span> <span class="ActionScriptBracket/Brace">{</span>                                
                <span class="ActionScriptDefault_Text">colA</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">ArrayCollection</span>;
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeABefore</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;
                <span class="ActionScriptReserved">for</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptOperator">=</span>0;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">&lt;</span><span class="ActionScriptDefault_Text">listSize</span>;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">++</span><span class="ActionScriptBracket/Brace">){</span>
                    <span class="ActionScriptDefault_Text">colA</span>.<span class="ActionScriptDefault_Text">addItem</span><span class="ActionScriptBracket/Brace">({</span><span class="ActionScriptDefault_Text">key</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">i</span>,<span class="ActionScriptDefault_Text">label</span><span class="ActionScriptOperator">:</span><span class="ActionScriptString">&quot;Value (&quot;</span><span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">+</span><span class="ActionScriptString">&quot;): &quot;</span><span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">Math</span>.<span class="ActionScriptDefault_Text">random</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">*</span>1000<span class="ActionScriptBracket/Brace">)})</span>;
                <span class="ActionScriptBracket/Brace">}</span>
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeAAfter</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;    
                <span class="ActionScriptDefault_Text">time1A</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">timeAAfter</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">-</span><span class="ActionScriptDefault_Text">timeABefore</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">())</span><span class="ActionScriptOperator">/</span>1000;                
            <span class="ActionScriptBracket/Brace">}</span>
            
            <span class="ActionScriptComment">// Fast version
</span>            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">createListB</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span> <span class="ActionScriptBracket/Brace">{</span>                
                <span class="ActionScriptDefault_Text">colB</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">ArrayCollection</span>;
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">tempCol</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">ArrayCollection</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">ArrayCollection</span>;
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeBBefore</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;
                <span class="ActionScriptReserved">for</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptOperator">=</span>0;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">&lt;</span><span class="ActionScriptDefault_Text">listSize</span>;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">++</span><span class="ActionScriptBracket/Brace">){</span>
                    <span class="ActionScriptDefault_Text">tempCol</span>.<span class="ActionScriptDefault_Text">addItem</span><span class="ActionScriptBracket/Brace">({</span><span class="ActionScriptDefault_Text">key</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">i</span>,<span class="ActionScriptDefault_Text">label</span><span class="ActionScriptOperator">:</span><span class="ActionScriptString">&quot;Value (&quot;</span><span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">+</span><span class="ActionScriptString">&quot;): &quot;</span><span class="ActionScriptOperator">+</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">Math</span>.<span class="ActionScriptDefault_Text">random</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">*</span>1000<span class="ActionScriptBracket/Brace">)})</span>;
                <span class="ActionScriptBracket/Brace">}</span>    
                <span class="ActionScriptDefault_Text">colB</span>.<span class="ActionScriptDefault_Text">source</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">tempCol</span>.<span class="ActionScriptDefault_Text">source</span>;
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeBAfter</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;
                <span class="ActionScriptDefault_Text">time1B</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">timeBAfter</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">-</span><span class="ActionScriptDefault_Text">timeBBefore</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">())</span><span class="ActionScriptOperator">/</span>1000;
            <span class="ActionScriptBracket/Brace">}</span>        
            <span class="ActionScriptComment">// ----------------------- TEST 1 - BINDINGS [END] ----------------    
</span>
            <span class="ActionScriptComment">// ----------------------- TEST 2 - BREAKING LOOPS [START] ----------------    
</span>            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">time2A</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> 0;
            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">time2B</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Number</span> <span class="ActionScriptOperator">=</span> 0;            
            <span class="ActionScriptBracket/Brace">[</span><span class="ActionScriptMetadata">Bindable</span><span class="ActionScriptBracket/Brace">]</span>
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">matrixDimension</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 1000;
                                
            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">startTest2</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>                
                <span class="ActionScriptDefault_Text">searchMatrixA</span><span class="ActionScriptBracket/Brace">()</span>;
                <span class="ActionScriptDefault_Text">searchMatrixB</span><span class="ActionScriptBracket/Brace">()</span>;            
            <span class="ActionScriptBracket/Brace">}</span>            
            
            <span class="ActionScriptComment">// Handle user matrix dimension change
</span>            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">dimensionChangeHandler</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptDefault_Text">matrixDimension</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">dimensionSize</span>.<span class="ActionScriptDefault_Text">text</span><span class="ActionScriptBracket/Brace">)</span>;
            <span class="ActionScriptBracket/Brace">}</span>
            
            <span class="ActionScriptComment">// Slow version
</span>            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">searchMatrixA</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeABefore</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;
                <span class="ActionScriptReserved">for</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 0;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">&lt;</span><span class="ActionScriptDefault_Text">matrixDimension</span>;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">++</span><span class="ActionScriptBracket/Brace">){</span>
                    <span class="ActionScriptReserved">for</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 0;<span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">&lt;</span><span class="ActionScriptDefault_Text">matrixDimension</span>;<span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">++</span><span class="ActionScriptBracket/Brace">){</span>
                        <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">((</span><span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">==</span><span class="ActionScriptDefault_Text">matrixDimension</span><span class="ActionScriptOperator">/</span>2<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">&amp;&amp;</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">==</span><span class="ActionScriptDefault_Text">matrixDimension</span><span class="ActionScriptOperator">/</span>2<span class="ActionScriptBracket/Brace">)){</span>
                            <span class="ActionScriptComment">// Do nothing
</span>                        <span class="ActionScriptBracket/Brace">}</span>
                    <span class="ActionScriptBracket/Brace">}</span>                        
                <span class="ActionScriptBracket/Brace">}</span>
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeAAfter</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;    
                <span class="ActionScriptDefault_Text">time2A</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">timeAAfter</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">-</span><span class="ActionScriptDefault_Text">timeABefore</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">())</span><span class="ActionScriptOperator">/</span>1000;        
            <span class="ActionScriptBracket/Brace">}</span>

            <span class="ActionScriptComment">// Fast version
</span>            <span class="ActionScriptReserved">private</span> <span class="ActionScriptfunction">function</span> <span class="ActionScriptDefault_Text">searchMatrixB</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">void</span><span class="ActionScriptBracket/Brace">{</span>
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeBBefore</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;
                <span class="ActionScriptDefault_Text">outer</span><span class="ActionScriptOperator">:</span><span class="ActionScriptReserved">for</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 0;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">&lt;</span><span class="ActionScriptDefault_Text">matrixDimension</span>;<span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">++</span><span class="ActionScriptBracket/Brace">){</span>
                    <span class="ActionScriptReserved">for</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span> <span class="ActionScriptOperator">=</span> 0;<span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">&lt;</span><span class="ActionScriptDefault_Text">matrixDimension</span>;<span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">++</span><span class="ActionScriptBracket/Brace">){</span>
                        <span class="ActionScriptReserved">if</span><span class="ActionScriptBracket/Brace">((</span><span class="ActionScriptDefault_Text">i</span><span class="ActionScriptOperator">==</span><span class="ActionScriptDefault_Text">matrixDimension</span><span class="ActionScriptOperator">/</span>2<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">&amp;&amp;</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">j</span><span class="ActionScriptOperator">==</span><span class="ActionScriptDefault_Text">matrixDimension</span><span class="ActionScriptOperator">/</span>2<span class="ActionScriptBracket/Brace">)){</span>
                            <span class="ActionScriptReserved">break</span> <span class="ActionScriptDefault_Text">outer</span>;
                        <span class="ActionScriptBracket/Brace">}</span>
                    <span class="ActionScriptBracket/Brace">}</span>                        
                <span class="ActionScriptBracket/Brace">}</span>
                <span class="ActionScriptvar">var</span> <span class="ActionScriptDefault_Text">timeBAfter</span><span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">Date</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptReserved">new</span> <span class="ActionScriptDefault_Text">Date</span>;    
                <span class="ActionScriptDefault_Text">time2B</span> <span class="ActionScriptOperator">=</span> <span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">timeBAfter</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">()</span><span class="ActionScriptOperator">-</span><span class="ActionScriptDefault_Text">timeBBefore</span>.<span class="ActionScriptDefault_Text">getTime</span><span class="ActionScriptBracket/Brace">())</span><span class="ActionScriptOperator">/</span>1000;        
            <span class="ActionScriptBracket/Brace">}</span>    
            <span class="ActionScriptComment">// ----------------------- TEST 2 - BREAKING LOOPS [END] ----------------                
</span>        <span class="ActionScriptBracket/Brace">]]</span><span class="ActionScriptOperator">&gt;</span>
    <span class="MXMLSpecial_Tag">&lt;/mx:Script&gt;</span>
    <span class="MXMLComment">&lt;!--</span><span class="MXMLComment"> TEST1 - BINDINGS </span><span class="MXMLComment">--&gt;</span>
    <span class="MXMLComponent_Tag">&lt;mx:Panel</span><span class="MXMLDefault_Text"> title=&quot;</span><span class="MXMLString">When to bind</span><span class="MXMLDefault_Text">&quot; horizontalAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot; paddingBottom=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingTop=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingLeft=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingRight=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">450</span><span class="MXMLDefault_Text">&quot; </span><span class="MXMLComponent_Tag">&gt;</span>        
        <span class="MXMLComponent_Tag">&lt;mx:HBox</span><span class="MXMLDefault_Text"> width=&quot;</span><span class="MXMLString">100%</span><span class="MXMLDefault_Text">&quot; horizontalAlign=&quot;</span><span class="MXMLString">right</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Button</span><span class="MXMLDefault_Text"> label=&quot;</span><span class="MXMLString">?</span><span class="MXMLDefault_Text">&quot; toolTip=&quot;</span><span class="MXMLString">{</span><span class="ActionScriptDefault_Text">explanation1</span><span class="MXMLString">}</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">30</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
        <span class="MXMLComponent_Tag">&lt;/mx:HBox&gt;</span>
        <span class="MXMLComponent_Tag">&lt;mx:HBox</span><span class="MXMLDefault_Text"> width=&quot;</span><span class="MXMLString">100%</span><span class="MXMLDefault_Text">&quot; verticalAlign=&quot;</span><span class="MXMLString">middle</span><span class="MXMLDefault_Text">&quot; backgroundColor=&quot;</span><span class="MXMLString">#EEEEEE</span><span class="MXMLDefault_Text">&quot; paddingBottom=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingTop=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingLeft=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingRight=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> text=&quot;</span><span class="MXMLString">List length:</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span><span class="MXMLComponent_Tag">&lt;mx:TextInput</span><span class="MXMLDefault_Text"> id=&quot;</span><span class="MXMLString">listSizeInput</span><span class="MXMLDefault_Text">&quot; text=&quot;</span><span class="MXMLString">{</span><span class="ActionScriptDefault_Text">listSize</span><span class="MXMLString">}</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">100</span><span class="MXMLDefault_Text">&quot; change=&quot;</span><span class="ActionScriptDefault_Text">listSizeChangeHandler</span><span class="ActionScriptBracket/Brace">()</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span> 
            <span class="MXMLComponent_Tag">&lt;mx:Button</span><span class="MXMLDefault_Text"> label=&quot;</span><span class="MXMLString">Start test</span><span class="MXMLDefault_Text">&quot; click=&quot;</span><span class="ActionScriptDefault_Text">startTest1</span><span class="ActionScriptBracket/Brace">()</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> id=&quot;</span><span class="MXMLString">running1</span><span class="MXMLDefault_Text">&quot; visible=&quot;</span><span class="MXMLString">false</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
        <span class="MXMLComponent_Tag">&lt;/mx:HBox&gt;</span>
        <span class="MXMLComponent_Tag">&lt;mx:HBox</span><span class="MXMLDefault_Text"> horizontalAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:VBox</span><span class="MXMLDefault_Text"> horizontalAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
                <span class="MXMLComponent_Tag">&lt;mx:List</span><span class="MXMLDefault_Text"> height=&quot;</span><span class="MXMLString">100</span><span class="MXMLDefault_Text">&quot; dataProvider=&quot;</span><span class="MXMLString">{</span><span class="ActionScriptDefault_Text">colA</span><span class="MXMLString">}</span><span class="MXMLDefault_Text">&quot; labelField=&quot;</span><span class="MXMLString">label</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">200</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
                <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> text=&quot;</span><span class="MXMLString">Time elapsed: {</span><span class="ActionScriptDefault_Text">time1A</span><span class="MXMLString">} seconds</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>            
            <span class="MXMLComponent_Tag">&lt;/mx:VBox&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:VBox</span><span class="MXMLDefault_Text"> horizontalAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
                <span class="MXMLComponent_Tag">&lt;mx:List</span><span class="MXMLDefault_Text"> height=&quot;</span><span class="MXMLString">100</span><span class="MXMLDefault_Text">&quot; dataProvider=&quot;</span><span class="MXMLString">{</span><span class="ActionScriptDefault_Text">colB</span><span class="MXMLString">}</span><span class="MXMLDefault_Text">&quot; labelField=&quot;</span><span class="MXMLString">label</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">200</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
                <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> text=&quot;</span><span class="MXMLString">Time elapsed: {</span><span class="ActionScriptDefault_Text">time1B</span><span class="MXMLString">} seconds</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>            
            <span class="MXMLComponent_Tag">&lt;/mx:VBox&gt;</span>
        <span class="MXMLComponent_Tag">&lt;/mx:HBox&gt;</span>
        <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> id=&quot;</span><span class="MXMLString">gain1</span><span class="MXMLDefault_Text">&quot; text=&quot;</span><span class="MXMLString">Performance increase: {</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">time1B</span><span class="ActionScriptOperator">==</span>0<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">?</span>0<span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">(((</span><span class="ActionScriptDefault_Text">time1A</span><span class="ActionScriptOperator">/</span><span class="ActionScriptDefault_Text">time1B</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">-</span>1<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">*</span>100<span class="ActionScriptBracket/Brace">)</span><span class="MXMLString">}%</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
    <span class="MXMLComponent_Tag">&lt;/mx:Panel&gt;</span>    
        
    <span class="MXMLComment">&lt;!--</span><span class="MXMLComment"> TEST2 - BREAKING LOOPS </span><span class="MXMLComment">--&gt;</span>
    <span class="MXMLComponent_Tag">&lt;mx:Panel</span><span class="MXMLDefault_Text"> title=&quot;</span><span class="MXMLString">Breaking loops</span><span class="MXMLDefault_Text">&quot; horizontalAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot; paddingBottom=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingTop=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingLeft=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingRight=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">450</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
        <span class="MXMLComponent_Tag">&lt;mx:HBox</span><span class="MXMLDefault_Text"> width=&quot;</span><span class="MXMLString">100%</span><span class="MXMLDefault_Text">&quot; horizontalAlign=&quot;</span><span class="MXMLString">right</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Button</span><span class="MXMLDefault_Text"> label=&quot;</span><span class="MXMLString">?</span><span class="MXMLDefault_Text">&quot; toolTip=&quot;</span><span class="MXMLString">{</span><span class="ActionScriptDefault_Text">explanation2</span><span class="MXMLString">}</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">30</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
        <span class="MXMLComponent_Tag">&lt;/mx:HBox&gt;</span>
        <span class="MXMLComponent_Tag">&lt;mx:HBox</span><span class="MXMLDefault_Text"> width=&quot;</span><span class="MXMLString">100%</span><span class="MXMLDefault_Text">&quot; verticalAlign=&quot;</span><span class="MXMLString">middle</span><span class="MXMLDefault_Text">&quot; backgroundColor=&quot;</span><span class="MXMLString">#EEEEEE</span><span class="MXMLDefault_Text">&quot; paddingBottom=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingTop=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingLeft=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot; paddingRight=&quot;</span><span class="MXMLString">10</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> text=&quot;</span><span class="MXMLString">Matrix dimension:</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span><span class="MXMLComponent_Tag">&lt;mx:TextInput</span><span class="MXMLDefault_Text"> id=&quot;</span><span class="MXMLString">dimensionSize</span><span class="MXMLDefault_Text">&quot; text=&quot;</span><span class="MXMLString">{</span><span class="ActionScriptDefault_Text">matrixDimension</span><span class="MXMLString">}</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">45</span><span class="MXMLDefault_Text">&quot; change=&quot;</span><span class="ActionScriptDefault_Text">dimensionChangeHandler</span><span class="ActionScriptBracket/Brace">()</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> text=&quot;</span><span class="MXMLString"> by {</span><span class="ActionScriptDefault_Text">matrixDimension</span><span class="MXMLString">}</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Button</span><span class="MXMLDefault_Text"> label=&quot;</span><span class="MXMLString">Start test</span><span class="MXMLDefault_Text">&quot; click=&quot;</span><span class="ActionScriptDefault_Text">startTest2</span><span class="ActionScriptBracket/Brace">()</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
        <span class="MXMLComponent_Tag">&lt;/mx:HBox&gt;</span>
        <span class="MXMLComponent_Tag">&lt;mx:HBox</span><span class="MXMLDefault_Text"> width=&quot;</span><span class="MXMLString">100%</span><span class="MXMLDefault_Text">&quot; horizontalAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> text=&quot;</span><span class="MXMLString">Time elapsed: {</span><span class="ActionScriptDefault_Text">time2A</span><span class="MXMLString">} seconds</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">100%</span><span class="MXMLDefault_Text">&quot; textAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
            <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> text=&quot;</span><span class="MXMLString">Time elapsed: {</span><span class="ActionScriptDefault_Text">time2B</span><span class="MXMLString">} seconds</span><span class="MXMLDefault_Text">&quot; width=&quot;</span><span class="MXMLString">100%</span><span class="MXMLDefault_Text">&quot; textAlign=&quot;</span><span class="MXMLString">center</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>        
        <span class="MXMLComponent_Tag">&lt;/mx:HBox&gt;</span>
        <span class="MXMLComponent_Tag">&lt;mx:Label</span><span class="MXMLDefault_Text"> id=&quot;</span><span class="MXMLString">gain2</span><span class="MXMLDefault_Text">&quot; text=&quot;</span><span class="MXMLString">Performance increase: {</span><span class="ActionScriptBracket/Brace">(</span><span class="ActionScriptDefault_Text">time2B</span><span class="ActionScriptOperator">==</span>0<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">?</span>0<span class="ActionScriptOperator">:</span><span class="ActionScriptDefault_Text">int</span><span class="ActionScriptBracket/Brace">(((</span><span class="ActionScriptDefault_Text">time2A</span><span class="ActionScriptOperator">/</span><span class="ActionScriptDefault_Text">time2B</span><span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">-</span>1<span class="ActionScriptBracket/Brace">)</span><span class="ActionScriptOperator">*</span>100<span class="ActionScriptBracket/Brace">)</span><span class="MXMLString">}%</span><span class="MXMLDefault_Text">&quot;</span><span class="MXMLComponent_Tag">/&gt;</span>
    <span class="MXMLComponent_Tag">&lt;/mx:Panel&gt;</span>    
<span class="MXMLComponent_Tag">&lt;/mx:Application&gt;</span></pre></body>
</html>
